package cn.edu.neu.studentmsg_java.service.impl;

import cn.edu.neu.studentmsg_java.dao.AppointmentDao;
import cn.edu.neu.studentmsg_java.dao.CourseDao;
import cn.edu.neu.studentmsg_java.dao.TeacherDao;
import cn.edu.neu.studentmsg_java.model.Appointment;
import cn.edu.neu.studentmsg_java.service.AppointmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AppointmentServiceImpl implements AppointmentService {
    @Autowired
    private AppointmentDao appointmentDao;
    @Autowired
    private CourseDao courseDao;
    @Autowired
    private TeacherDao teacherDao;

    @Override
    public List<String> findTeacherNameByCourseName(String course_name) {
        return appointmentDao.selectTeacherNameByCourseName(course_name);
    }

    @Override
    public int removeAppointmentByTeacherIdAndCourseId(Appointment appointment) {
        return appointmentDao.deleteAppointmentByTeacherIdAndCourseId(appointment);
    }

    @Override
    public List<String> findCourseNameByTeacherName(String teacher_name) {
        return appointmentDao.selectCourseNameByTeacherName(teacher_name);
    }

    @Override
    public List<Appointment> findAppointmentPart(Appointment appointment) {
        return appointmentDao.selectAppointmentPart(appointment);
    }

    @Override
    public int addApprointmentByTNameAndCId(Appointment appointment) {
        appointment.setTeacher_id(teacherDao.selectTeacherIdByTeacherName(appointment.getTeacher_name()));
        return appointmentDao.insertApprointmentByTIdAndCId(appointment);
    }

    @Override
    public List<Appointment> findAppointmentCPart(Appointment appointment) {
        return appointmentDao.selectAppointmentCPart(appointment);
    }

    @Override
    public List<Appointment> findAppointmentTPart(Appointment appointment) {
        return appointmentDao.selectAppointmentTPart(appointment);
    }

    @Override
    public int addApprointmentByTIdAndCName(Appointment appointment) {
        appointment.setCourse_id(courseDao.selectCourseIdByCourseName(appointment.getCourse_name()));
        return appointmentDao.insertApprointmentByTIdAndCId(appointment);
    }
}
